package com.cy;

import redis.clients.jedis.Jedis;

import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class RedisApplication {
    public static void main(String[] args) {
        Jedis jedis = new Jedis("43.139.15.42",6379);
        System.out.println("连接成功");
        System.out.println("服务正在运行："+jedis.ping());
        //5大类型
        jedis.set("hello1","jx220304曹大帅");
        System.out.println(jedis.get("hello1"));

        jedis.hset("helloo","jx220302","敏雄");
        jedis.hset("helloo","jx220301","旭东");
        Map<String,String> map = jedis.hgetAll("helloo");
        Set<String> keys = map.keySet();
        Iterator<String> it = keys.iterator();
        while (it.hasNext()){
            System.out.println(it.next()); //取到key
        }

        Collection values = map.values();
        Iterator<String> itval = values.iterator();
        while (itval.hasNext()){
            System.out.println(itval.next()); //取到值
        }

//        for (Map.Entry<String, String> entry : map.entrySet()) {
//            System.out.println(entry.getKey());
//        }

    }


}
